package com.tddx.activiti.business.sys.controller.systmenu;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.tddx.activiti.business.sys.entity.systmenu.SysTmenuEntity;
import com.tddx.activiti.business.sys.service.systmenu.SysTmenuService;

/**
 * control layer 控制层 
 * @Auth yanweizhao 
*/
@Controller
@RequestMapping("sys/systmenu")
public class SysTmenuCtrl {

	@Autowired private SysTmenuService service;

	@RequestMapping("view{oper}")
	public String view(@PathVariable String oper, Long id, ModelMap model){
		model.put("oper", oper);
		if("result".equals(oper)){
			return "modules/sys/sysTmenuList";
		}
		if(id!=null){
			SysTmenuEntity entity = service.findOne(id);
			model.put("entity", entity);
		}
		return "modules/sys/sysTmenuInput";
	}
	
	@RequestMapping("save")
	@ResponseBody
	public SysTmenuEntity save(SysTmenuEntity entity){
		entity = service.save(entity);
		return entity;
	}
	
	@RequestMapping("delete")
	@ResponseBody
	public Object delete(String ids){
		service.delete(ids);
		return ids;
	}
	
	@RequestMapping({"list", ""})
	@ResponseBody
	public Object findList(){
		Object obj = service.findList();
		return obj;
	}
}
